package com.yq.design.flyWeight;

import java.util.HashMap;

/**
 * @ClassName FlyWeightFactory
 * @Description 享元工厂类，构建一个池容器，同时提供从池容器中获取对象，如果没有就创建新的，有就直接返回
 * @Author yaoqiang
 * @Date 2021/2/22 23:42
 * @Version 1.0
 */
public class FlyWeightFactory {
  private   HashMap<String, ConcreteWebSite> pool=new HashMap<>();

    public WebSite getWebSite(String type){
        if(!pool.containsKey(type)){
            pool.put(type,new ConcreteWebSite(type));
        }
        return (WebSite)pool.get(type);
    }

    public void getLength(){
        System.out.println(pool.size());
    }
}
